@import "tailwindcss";

:root {
  --background: #ffffff;
  --foreground: #171717;
  --border: #d9d9d9;
  --border-hover: #40a9ff;
  --panel-bg: #fafafa;
  --panel-header-bg: #f5f5f5;
  --success-color: #52c41a;
  --error-color: #ff4d4f;
  --warning-color: #faad14;
  --info-color: #1890ff;

  /* 扩展颜色系统 */
  --primary-50: #e6f7ff;
  --primary-100: #bae7ff;
  --primary-200: #91d5ff;
  --primary-300: #69c0ff;
  --primary-400: #40a9ff;
  --primary-500: #1890ff;
  --primary-600: #096dd9;
  --primary-700: #0050b3;
  --primary-800: #003a8c;
  --primary-900: #002766;

  /* 灰度系统 */
  --gray-50: #fafafa;
  --gray-100: #f5f5f5;
  --gray-200: #f0f0f0;
  --gray-300: #d9d9d9;
  --gray-400: #bfbfbf;
  --gray-500: #8c8c8c;
  --gray-600: #595959;
  --gray-700: #434343;
  --gray-800: #262626;
  --gray-900: #1f1f1f;

  /* 阴影系统 */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);

  /* 圆角系统 */
  --radius-sm: 2px;
  --radius: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-xl: 12px;
  --radius-2xl: 16px;
  --radius-full: 9999px;

  /* 间距系统 */
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 12px;
  --spacing-lg: 16px;
  --spacing-xl: 20px;
  --spacing-2xl: 24px;
  --spacing-3xl: 32px;
}

[data-theme="dark"] {
  --background: #141414;
  --foreground: #ffffff;
  --border: #434343;
  --border-hover: #177ddc;
  --panel-bg: #1f1f1f;
  --panel-header-bg: #262626;

  /* 暗色模式颜色调整 */
  --primary-50: #002766;
  --primary-100: #003a8c;
  --primary-200: #0050b3;
  --primary-300: #096dd9;
  --primary-400: #1890ff;
  --primary-500: #40a9ff;
  --primary-600: #69c0ff;
  --primary-700: #91d5ff;
  --primary-800: #bae7ff;
  --primary-900: #e6f7ff;
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
}

body {
  background: var(--background);
  color: var(--foreground);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
    'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
    sans-serif;
  margin: 0;
  padding: 0;
  height: 100%;
  overflow-x: hidden;
}

/* 应用容器 */
.app-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* 医学影像查看器样式增强 */
.viewer-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--panel-bg);
  transition: all 0.3s ease;
  box-shadow: var(--shadow-sm);
}

.viewer-panel:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.viewer-panel:focus-within {
  border-color: var(--primary-500);
  box-shadow: 0 0 0 3px rgba(24, 144, 255, 0.1);
}

.viewer-panel canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  background: #000;
  transition: opacity 0.2s ease;
}

.viewer-panel canvas:hover {
  opacity: 0.95;
}

.panel-header {
  background: linear-gradient(135deg, var(--panel-header-bg) 0%, var(--gray-100) 100%);
  padding: var(--spacing-sm) var(--spacing-md);
  font-size: 14px;
  font-weight: 500;
  border-bottom: 1px solid var(--border);
  user-select: none;
  position: relative;
  overflow: hidden;
}

.panel-header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--primary-500), var(--primary-300));
  opacity: 0;
  transition: opacity 0.3s ease;
}

.viewer-panel:hover .panel-header::before {
  opacity: 1;
}

/* 面板状态指示器 */
.panel-status {
  position: absolute;
  top: var(--spacing-sm);
  right: var(--spacing-sm);
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--success-color);
  box-shadow: 0 0 0 2px rgba(82, 196, 26, 0.2);
  animation: pulse 2s infinite;
}

.panel-status.loading {
  background: var(--warning-color);
  box-shadow: 0 0 0 2px rgba(250, 173, 20, 0.2);
}

.panel-status.error {
  background: var(--error-color);
  box-shadow: 0 0 0 2px rgba(255, 77, 79, 0.2);
}

/* 工具箱样式增强 */
.toolbox-container {
  background: linear-gradient(180deg, var(--background) 0%, var(--gray-50) 100%);
  border-right: 1px solid var(--border);
  height: 100vh;
  overflow-y: auto;
  position: relative;
}

.toolbox-container::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 1px;
  height: 100%;
  background: linear-gradient(180deg, transparent 0%, var(--border) 50%, transparent 100%);
  pointer-events: none;
}

.viewer-container {
  background: var(--panel-bg);
  height: 100vh;
  overflow: hidden;
  position: relative;
}

/* 工具箱卡片增强 */
.toolbox .ant-card {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.toolbox .ant-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
  transition: left 0.5s ease;
}

.toolbox .ant-card:hover::before {
  left: 100%;
}

.toolbox .ant-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.toolbox .ant-card:active {
  transform: translateY(0);
  transition: transform 0.1s ease;
}

/* 数据集图标增强 */
.dataset-icon {
  transition: all 0.3s ease;
  position: relative;
}

.dataset-icon::after {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: inherit;
  background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.3), transparent);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.toolbox .ant-card:hover .dataset-icon::after {
  opacity: 1;
}

/* 选中状态增强 */
.toolbox .ant-card.selected {
  border-color: var(--primary-500);
  background: linear-gradient(135deg, var(--primary-50) 0%, var(--background) 100%);
  box-shadow: 0 0 0 3px rgba(24, 144, 255, 0.1);
}

.toolbox .ant-card.selected .dataset-icon {
  transform: scale(1.1);
  box-shadow: var(--shadow-md);
}

/* 加载状态 */
.loading-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-radius: 50%;
  border-top-color: var(--info-color);
  animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* 响应式设计 */
@media (max-width: 1024px) {
  .main-view {
    flex-direction: column;
  }

  .toolbox-container {
    height: auto;
    max-height: 200px;
    border-right: none;
    border-bottom: 1px solid var(--border);
    overflow-y: auto;
  }

  .viewer-container {
    height: calc(100vh - 200px);
    min-height: 400px;
  }

  /* 3D查看器移动端优化 */
  .viewer-3d .viewer-grid {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto;
  }

  /* 2D查看器移动端优化 */
  .viewer-2d {
    flex-direction: column;
  }

  .viewer-2d .side-area {
    width: 100%;
    height: 200px;
    flex-direction: row;
  }
}

@media (max-width: 768px) {
  .toolbox-container {
    max-height: 150px;
  }

  .viewer-container {
    height: calc(100vh - 150px);
  }

  /* 进一步简化移动端界面 */
  .panel-header {
    padding: 6px 8px;
    font-size: 12px;
  }

  /* 隐藏一些非关键元素 */
  .viewer-status {
    display: none;
  }
}

@media (max-width: 640px) {
  .toolbox-container {
    max-height: 120px;
  }

  .viewer-container {
    height: calc(100vh - 120px);
  }

  /* 超小屏幕优化 */
  .viewer-header {
    padding: 8px 12px;
  }

  .viewer-header .ant-typography {
    font-size: 14px;
  }
}

/* 滚动条样式 */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--panel-bg);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--border-hover);
}

/* 选择文本样式 */
::selection {
  background: var(--info-color);
  color: white;
}

/* 焦点样式 */
button:focus,
input:focus,
select:focus,
textarea:focus {
  outline: 2px solid var(--info-color);
  outline-offset: 2px;
}

/* 禁用状态 */
.disabled {
  opacity: 0.6;
  cursor: not-allowed;
  pointer-events: none;
}

/* 动画和过渡效果 */
.fade-in {
  animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.slide-in {
  animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
  from {
    transform: translateY(-10px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.slide-in-left {
  animation: slideInLeft 0.3s ease-out;
}

@keyframes slideInLeft {
  from {
    transform: translateX(-20px);
    opacity: 0;
  }

  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.scale-in {
  animation: scaleIn 0.2s ease-out;
}

@keyframes scaleIn {
  from {
    transform: scale(0.95);
    opacity: 0;
  }

  to {
    transform: scale(1);
    opacity: 1;
  }
}

/* 加载动画增强 */
.loading-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-radius: 50%;
  border-top-color: var(--info-color);
  animation: spin 1s ease-in-out infinite;
}

.loading-spinner-large {
  width: 40px;
  height: 40px;
  border-width: 3px;
}

.loading-dots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.loading-dots::after {
  content: '';
  display: inline-block;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--info-color);
  animation: loadingDots 1.4s infinite ease-in-out both;
}

.loading-dots::before {
  content: '';
  display: inline-block;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--info-color);
  animation: loadingDots 1.4s infinite ease-in-out both;
  animation-delay: -0.16s;
  margin-right: 4px;
}

@keyframes loadingDots {

  0%,
  80%,
  100% {
    transform: scale(0);
    opacity: 0.5;
  }

  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* 脉冲动画 */
.pulse {
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.05);
  }

  100% {
    transform: scale(1);
  }
}

/* 悬停效果增强 */
.hover-lift {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.hover-lift:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.hover-glow {
  transition: box-shadow 0.2s ease;
}

.hover-glow:hover {
  box-shadow: 0 0 20px rgba(24, 144, 255, 0.3);
}

/* 按钮动画 */
.btn-ripple {
  position: relative;
  overflow: hidden;
}

.btn-ripple::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transform: translate(-50%, -50%);
  transition: width 0.3s, height 0.3s;
}

.btn-ripple:active::before {
  width: 300px;
  height: 300px;
}

/* 进度条动画 */
.progress-bar {
  position: relative;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
  animation: shimmer 2s infinite;
}

@keyframes shimmer {
  0% {
    left: -100%;
  }

  100% {
    left: 100%;
  }
}

/* 骨架屏动画 */
.skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite;
}

@keyframes skeleton-loading {
  0% {
    background-position: 200% 0;
  }

  100% {
    background-position: -200% 0;
  }
}

/* 错误边界样式 */
.error-boundary-container {
  background: var(--background);
  color: var(--foreground);
}

/* 通知系统动画 */
@keyframes slide-in-right {
  from {
    transform: translateX(100%);
    opacity: 0;
  }

  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slide-out-right {
  from {
    transform: translateX(0);
    opacity: 1;
  }

  to {
    transform: translateX(100%);
    opacity: 0;
  }
}

/* 通知动画类 */
.animate-slide-in-right {
  animation: slide-in-right 0.3s ease-out;
}

.animate-slide-out-right {
  animation: slide-out-right 0.3s ease-in;
}

/* 加载指示器样式 */
.loading-overlay {
  backdrop-filter: blur(2px);
}

/* 通知容器样式 */
.notification-container {
  max-height: calc(100vh - 32px);
  overflow-y: auto;
}

.notification-container::-webkit-scrollbar {
  width: 4px;
}

.notification-container::-webkit-scrollbar-track {
  background: transparent;
}

.notification-container::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 2px;
}

.notification-container::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.3);
}

/* 通知样式增强 */
.notification-enter {
  transform: translateX(100%);
  opacity: 0;
}

.notification-enter-active {
  transform: translateX(0);
  opacity: 1;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.notification-exit {
  transform: translateX(0);
  opacity: 1;
}

.notification-exit-active {
  transform: translateX(100%);
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

/* 导航头部增强 */
.navigation-header {
  backdrop-filter: blur(8px);
  background: rgba(255, 255, 255, 0.95);
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

[data-theme="dark"] .navigation-header {
  background: rgba(31, 31, 31, 0.95);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

/* 主题切换按钮 */
.theme-toggle-btn {
  border-radius: var(--radius-full);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.theme-toggle-btn:hover {
  background: var(--primary-50);
  transform: scale(1.1);
}

[data-theme="dark"] .theme-toggle-btn:hover {
  background: var(--primary-900);
}

/* 工具提示增强 */
.ant-tooltip {
  z-index: 1060;
}

.ant-tooltip-inner {
  border-radius: var(--radius);
  font-size: 12px;
  padding: 6px 8px;
}

/* 卡片悬停效果增强 */
.ant-card {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.ant-card:hover {
  transform: translateY(-1px);
}

/* 按钮增强 */
.ant-btn {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: var(--radius);
}

.ant-btn:hover {
  transform: translateY(-1px);
}

.ant-btn:active {
  transform: translateY(0);
}

/* 滑块增强 */
.ant-slider {
  margin: 8px 0;
}

.ant-slider-handle {
  transition: all 0.3s ease;
}

.ant-slider-handle:hover {
  transform: scale(1.2);
}

/* 输入框增强 */
.ant-input,
.ant-select-selector {
  transition: all 0.3s ease;
  border-radius: var(--radius);
}

.ant-input:focus,
.ant-select-focused .ant-select-selector {
  box-shadow: 0 0 0 3px rgba(24, 144, 255, 0.1);
}

/* 表格增强 */
.ant-table {
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.ant-table-thead>tr>th {
  background: var(--gray-50);
  border-bottom: 2px solid var(--border);
}

[data-theme="dark"] .ant-table-thead>tr>th {
  background: var(--gray-800);
}

/* 模态框增强 */
.ant-modal {
  border-radius: var(--radius-xl);
  overflow: hidden;
}

.ant-modal-content {
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
}

/* 抽屉增强 */
.ant-drawer-content {
  border-radius: var(--radius-lg);
}

/* 消息增强 */
.ant-message {
  z-index: 1070;
}

.ant-message-notice {
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

/* 通知增强 */
.ant-notification {
  z-index: 1070;
}

.ant-notification-notice {
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

/* 打印样式 */
@media print {
  .no-print {
    display: none !important;
  }

  .app-container {
    background: white !important;
    color: black !important;
  }
}